﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="FileInfo.cs" company="Collaboris Ltd.">
//   Copyright (c) Collaboris Ltd. All rights Reserved.
// </copyright>
// <summary>
//   Defines a Class to located and get Files 
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace Collaboris.Saf.Actions.Entities
{
    using System;
    using System.Collections.Generic;

    using System.IO;

    using SharePoint.Wss.Attributes;
    using SharePoint.Wss.Entities;

    [CollaborisClass(
          Title = "File Info",
          ReleaseStatus = ReleaseStatus.Stable,
          DisableDocumentation = false,
          ContactAuthorEmail = "Support@Collaboris.co.uk",
          Summary = "Defines the parameters to locate and output a list of file names.",
          Remarks = "The list of filenames is stored in a property within the entity called 'FileNames'. " +
                    "This can then be passed into subsequent actions using output properties."
      )]
    [Serializable]
    public class FileInfo : EntityBase
    {
        /// <summary>
        /// The path.
        /// </summary>
        private string path;

        /// <summary>
        /// The files names.
        /// </summary>
        private List<string> fileNames;

        /// <summary>
        /// The pattern.
        /// </summary>
        private string pattern;

        /// <summary>
        /// The search option.
        /// </summary>
        private SearchOption searchOption;
    
        [CollaborisProperty(
              Summary = "The local file path containing the files.",
              Title = "Path",
              Example = @"c:\temp",
              Required = true,
              InputHint = InputHint.FileUrl
        )]
        public string Path
        {
            get
            {
                return this.path;
            }

            set
            {
                this.path = value;
            }
        }

        [CollaborisProperty(
              Summary = "Contains a list of the file names found in the 'Path'.",
              Title = "File Names",
              OutputProperty = true
        )]
        public List<string> FileNames
        {
            get
            {
                return this.fileNames;
            }

            set
            {
                this.fileNames = value;
            }
        }

        [CollaborisProperty(
              Summary = "The search string to match against the names of files in the path.",
              Title = "Search Pattern",
              Example = @"*.doc",
              Required = true,
              InputHint = InputHint.SingleText,
              Remarks = @"The parameter cannot end in two periods ("".."") or " +
                        @"contain two periods ("".."") followed by " +
                        @"<a href=""http://msdn.microsoft.com/en-us/library/system.io.path.directoryseparatorchar.aspx"">DirectorySeparatorChar</a> or " +
                        @"<a href=""http://msdn.microsoft.com/en-us/library/system.io.path.altdirectoryseparatorchar.aspx"">AltDirectorySeparatorChar</a>, nor can " +
                        @"it contain  any of the characters " +
                        @"in <a href=""http://msdn.microsoft.com/en-us/library/system.io.path.getinvalidfilenamechars.aspx"">GetInvalidFileNameChars</a>. "
        )]
        public string SearchPattern
        {
            get
            {
                return this.pattern;
            }

            set
            {
                this.pattern = value;
            }
        }

        [CollaborisProperty(
              Summary = "Specifies whether to search the current directory, or the current directory and all subdirectories.",
              Title = "Search Option",
              Example = @"AllDirectories",
              Required = true,
              InputHint = InputHint.Enum,
              Remarks = @"Please supply 'AllDirectories' or 'TopDirectoryOnly' as possible values." 
        )]
        public SearchOption SearchOption
        {
            get
            {
                return this.searchOption;
            }

            set
            {
                this.searchOption = value;
            }
        }
    }
}
